package com.iris.thread.concurrent;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 项目: thinking
 * 包名: com.iris.thread.concurrent
 * 作者: victor
 * 日期: 2016年10月30日
 * 说明: CopyOnwriteArrayMain
 */
public class CopyOnwriteArrayMain {
	private static final int THREAD_POOL_SIZE = 2;

    public static void main(String[] args) {
//    	List<Double> list = new ArrayList<Double>();
    	CopyOnWriteArrayList<Double> list = new CopyOnWriteArrayList<Double>();
        ExecutorService es = Executors.newFixedThreadPool(THREAD_POOL_SIZE);
        es.execute(new CopyOnwriteArray(list));
        es.execute(new CopyOnwriteArray(list));
        try {
			Thread.sleep(3000);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
        System.out.println(list.size());
        es.shutdown();
    }
}
